package ui.juego

import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Selector
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.bindings.PropertyAdapter
import dominio.individuos.Villano
import ui.juego.utilidades.IconUtils

class EmitirOrdenDeArrestoDialog extends Dialog<EmitirOrdenDeArresto> {
	
	new(WindowOwner owner, EmitirOrdenDeArresto model) {
		super(owner, model)
		title = '''Resolviendo: «modelObject.investigacion.caso.nombre»'''
		iconImage = IconUtils.path
	}
	
	override protected createFormPanel(Panel mainPanel) {}
	
	override createMainTemplate(Panel mainPanel) {
		val contentPanel = new Panel(mainPanel) => [
			layout = new VerticalLayout
		]
		new Selector(contentPanel) => [
			bindItemsToProperty("investigacion.caso.expedientes.villanos").adapter = new PropertyAdapter(Villano, "nombre")
			bindValueToProperty("villanoSeleccionado")
		]
		new Button(contentPanel) => [
			caption = "Generar Orden de Arresto"
			onClick[ |
				modelObject.emitirOrdenContraVillanoSeleccionado
				close
			]
		]
	}
	
}